package GUI;

import java.util.ArrayList;

import Control.Character;
import processing.core.PImage;


class CharacterButton extends Component
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	public CharacterButton()
	{
		width =  165;
		height = 25;
	}
	public void setLabel(String name)
	{
		label = name;

	}
	public void draw()
	{
		Utils.globalProcessing.textFont(Utils.plotFont, 19);
		int cx = x;
		int cy = y;
		if(label != null)
		{
			Utils.globalProcessing.textAlign(Utils.globalProcessing.LEFT);

			if(mouseOver()) 
			{
				super.draw();
				if(Utils.globalProcessing.mousePressed)
				{

					Utils.gu.drawVGradient(x, y + height, width, -height, Utils.globalProcessing.color(150, 150, 180), 80, Utils.globalProcessing.color(150, 150, 180), 255, (float)0.8);    
					Utils.gu.drawBox(x, y, width, height, 0, Utils.globalProcessing.color(150, 150, 200), 255);
					Utils.gu.drawBox(x, y, width, height, 1, Utils.globalProcessing.color(150, 150, 200), 150);
					cx += 2;
					cy += 2;

					//add the character to the list or remove it if it is already present
					if(Utils.characterSelected.contains(c)){
						Utils.ccip.removeCharacterSelected(c);
					}
					else{
						Utils.ccip.addCharacterSelected(c);
					}
					Utils.characterTextBox.active=false;
					//Utils.characterTextBox.text = c.getShortName(); 

				}
			}

			Utils.globalProcessing.strokeWeight(1);
			Utils.globalProcessing.fill(255);
			Utils.globalProcessing.text(label, cx + 5, cy + 20);

		}
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////
	PImage icon;
	String label;
	public Character c;
	////////////////////////////////////////////////////////////////////////////////////////////////////
	public void setCharacter(Character character) {
		this.c=character;
		
	}
}